<template>
  <div class="right">
    <div class="g-wrap">


      <div class="u-title">
        <h3>
          <span class="f-ff2">{{title.name}}</span>
        </h3>
      </div>


      <ul class="n-ltlst">
        <li v-for="(item,index) in nlist" :key="index">
          <a href="javascript:;" :class="item===activeName?hot:''" @click.prevent="toOther(item)">{{ item }}</a>
        </li>
      </ul>
      <div class="m-sgerlist">
        <ul class="m-cvrlst">

          <!--判断路径-->
          <li v-for="(singer,index) in singerList1" :key="index">
            <div class="u-cover">
              <img v-lazy="singer.img1v1Url" alt="">
              <router-link :to="{name:'Work',params:{id:singer.id}}" class="main-de"></router-link>
            </div>
            <p>
              <router-link :to="{name:'Work',params:{id:singer.id}}" class="music">{{ singer.name }}</router-link>
              <router-link class="detail" v-if="singer.accountId" :to="{name:'UserDetail',params:{id:singer.accountId}}">
                <i class="icon-de"></i>
              </router-link>
            </p>
          </li>
        </ul>
      </div>

      <div style="background-color: #D3D3D3;height: 1px;"></div>
      <ul class="m-cvrlst-5">
        <li class="sml" v-for="(singer,index) in singerList2" :key="index">
          <router-link :to="{name:'Work',params:{id:singer.id}}" class="music1">{{ singer.name }}</router-link>
          <router-link :to="{name:'UserDetail',params:{id:singer.accountId}}" class="detail1" v-if="singer.accountId">
            <i class="icon-de"></i>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>

import {mapState} from "vuex";

export default {
  name: "index",
  data() {
    return {
      nlist: [],
      hot: 'f-fs0 cit ',
      singerList1: [],
      singerList2: [],
      activeName: '热门'
    }
  },
  computed:{
    ...mapState('banner',['artLists']),
    title(){
      let type = this.$route.query.type
      let area = this.$route.query.area
      let result = this.artLists.find(item=>{
        return item.area == area
      })
      return result.typeName.find(item=>{
        return item.id == type
      })
    }
  },
  methods: {
    async toOther(str) {
      let initial = ''
      if (str === '其他') initial = '0'
      else if (str === '热门') initial = '-1'
      else initial = str
      await this.$router.push({
        name: 'OtherArtistView',
        query: {type: this.$route.query.type, area: this.$route.query.area, initial: initial}
      })
    },
    async getSinger() {
      let result = await this.$API.reqArtistsList(this.$route.query.type, this.$route.query.area, this.$route.query.initial)
      this.singerList1 = result.data.artists.slice(0, 10)
      this.singerList2 = result.data.artists.slice(10)
    }
  },
  created() {
    this.nlist.push('热门');
    for (let i = 0; i < 26; i++) {
      this.nlist.push(String.fromCharCode(65 + i));
    }
    this.nlist.push('其他');
    this.getSinger()
    if (this.$route.query.initial) {
      if (this.$route.query.initial =='-1') {
        this.activeName = '热门'
      } else if (this.$route.query.initial == '0') {
        this.activeName = '其他'
      }
      else {
        this.activeName = this.$route.query.initial
      }
    }
  }
}
</script>

<style scoped lang="less">
.right {
  border-left: 1px solid #D3D3D3;

  .g-wrap {
    padding: 40px;

    .u-title {
      height: 40px;
      border-bottom: 2px solid #c20c0c;

      h3 {
        float: left;
        font-size: 24px;
        font-weight: normal;

        .f-ff2 {
          font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
        }
      }

      .more {
        float: right;
        margin-top: 14px;
        color: #666;
      }
    }

    .n-ltlst {
      margin-top: 20px;
      margin-left: -3px;
      height: auto;
      overflow: hidden;

      li {
        display: inline;
        float: left;
        margin-left: 3px;
        font-size: 14px;
        text-align: center;
        line-height: 24px;
        &:first-child {
          a {
            width: 45px;
            font-size: 12px;
          }
        }
        &:last-child {
          a {
            width: 45px;
            font-size: 12px;
          }
        }

        a {
          float: left;
          width: 21px;
          line-height: 24px;
          text-align: center;
          color: #333;
        }
      }

      .f-fs0 {
        font-size: 12px;
      }

      .cit {
        background: #c20c0c;
        border-radius: 2px;
        color: #fff;
      }

      .ch {
        display: block;
        width: 45px;
        height: 24px;
      }
    }

    .m-sgerlist {
      width: 736px;
      height: auto;
      margin: 20px auto auto auto;
      overflow: hidden;

      .m-cvrlst {
        width: 758px;
        height: auto;
        overflow: hidden;

        li {
          width: 130px;
          margin-right: 21px;
          margin-bottom: 30px;
          height: 154px;
          float: left;
          display: inline-block;
          overflow: hidden;
          line-height: 1.4;

          .u-cover {
            width: 130px;
            height: 130px;
            position: relative;
            display: block;

            img {
              width: 100%;
              height: 100%;
              display: inline-block;
            }

            .main-de {
              position: absolute;
              top: 0;
              left: 0;
              width: 100%;
              height: 100%;
              background-image: url("../../../assets/coverall.png");
              background-position: 0 -680px;
            }
          }

          p {
            margin-top: 8px;
            width: 100%;

            .music {
              float: left;
              max-width: 80%;
              color: #000;
            }

            .detail {
              float: right;

              .icon-de {
                width: 17px;
                height: 18px;
                background-position: 0 -740px;
                margin-top: -1px;
                display: inline-block;
                overflow: hidden;
                vertical-align: middle;
                background-image: url("../../../assets/icon.png");
              }
            }
          }
        }
      }
    }

    .m-cvrlst-5 {
      width: 736px;
      height: auto;
      margin-top: 10px;
      overflow: hidden;

      .sml {
        height: 30px;
        width: 130px;
        float: left;
        margin-left: 17px;
        padding-bottom: 0;
        line-height: 23px;

        .music1 {
          float: left;
          color: #000;
          max-width: 80%;
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }

        .detail1 {
          float: left;
          width: 17px;
          height: 18px;
          display: inline-block;
          margin-left: 2px;

          .icon-de {
            width: 17px;
            height: 18px;
            background-position: 0 -740px;
            margin-top: -1px;
            display: inline-block;
            overflow: hidden;
            vertical-align: middle;
            background-image: url("../../../assets/icon.png");
          }
        }
      }
    }
  }
}
</style>